package com.soft.service;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;

import com.soft.entity.Class;
import com.soft.entity.Student;

@SpringBootTest
public class ClassServiceTest {
    @Autowired
    private ClassService classService;

    // @Test
    public void queryAllTest() {
        List<Class> classList = classService.queryAll();
        Assert.notEmpty(classList, "为空");
        Assert.isTrue(classList.size() > 0, "有值");
        for (int i = 0; i < classList.size(); i++) {
            System.out.println(classList.get(i).getName());
        }
    }

    // @Test
    public void testInsert() {
        int num = classService.insert("软件工程2班", "JSJ202", "1");
        Assert.isTrue(num == 1, "插入数据错误");
    }

    // @Test
    public void updateByIdTest() {
        int num = classService.updateNumById("10", "JSJ203");
        Assert.isTrue(num > 0, "修改数据错误");
    }

     //@Test
    public void deleteByIdTest() {
        int num = classService.deleteById("10");
        Assert.isTrue(num == 1, "删除数据错误");
    }
      @Test
    public void getStudentsByClassNameTest() {
        List<Student> students = classService.getStudentsByClassName("计算机科学与技术1班");
        Assert.notEmpty(students, "学生列表为空");
        for (Student student : students) {
            System.out.println(student.getName());
        }
    }
    
    
}